﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;

    [ScriptType("SP.FieldUser", ServerTypeId="{ebd2fb89-e8a2-46c4-b317-9b2347121765}")]
    public class FieldUser : FieldLookup
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public FieldUser(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (!flag)
            {
                string str = peekedName;
                if (str == null)
                {
                    return flag;
                }
                if (!(str == "Presence"))
                {
                    if (str == "AllowDisplay")
                    {
                        flag = true;
                        reader.ReadName();
                        base.ObjectData.Properties["AllowDisplay"] = reader.ReadBoolean();
                        return flag;
                    }
                    if (str == "SelectionMode")
                    {
                        flag = true;
                        reader.ReadName();
                        base.ObjectData.Properties["SelectionMode"] = reader.ReadEnum<FieldUserSelectionMode>();
                        return flag;
                    }
                    if (str == "SelectionGroup")
                    {
                        flag = true;
                        reader.ReadName();
                        base.ObjectData.Properties["SelectionGroup"] = reader.ReadInt32();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                base.ObjectData.Properties["Presence"] = reader.ReadBoolean();
            }
            return flag;
        }

        [Remote]
        public bool AllowDisplay
        {
            get
            {
                base.CheckUninitializedProperty("AllowDisplay");
                return (bool) base.ObjectData.Properties["AllowDisplay"];
            }
            set
            {
                base.ObjectData.Properties["AllowDisplay"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "AllowDisplay", value));
                }
            }
        }

        [Remote]
        public bool Presence
        {
            get
            {
                base.CheckUninitializedProperty("Presence");
                return (bool) base.ObjectData.Properties["Presence"];
            }
            set
            {
                base.ObjectData.Properties["Presence"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "Presence", value));
                }
            }
        }

        [Remote]
        public int SelectionGroup
        {
            get
            {
                base.CheckUninitializedProperty("SelectionGroup");
                return (int) base.ObjectData.Properties["SelectionGroup"];
            }
            set
            {
                base.ObjectData.Properties["SelectionGroup"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "SelectionGroup", value));
                }
            }
        }

        [Remote]
        public FieldUserSelectionMode SelectionMode
        {
            get
            {
                base.CheckUninitializedProperty("SelectionMode");
                return (FieldUserSelectionMode) base.ObjectData.Properties["SelectionMode"];
            }
            set
            {
                base.ObjectData.Properties["SelectionMode"] = value;
                if (base.Context != null)
                {
                    base.Context.AddQuery(new ClientActionSetProperty(this, "SelectionMode", value));
                }
            }
        }
    }
}

